﻿/*****************************************************************//**
 *
 * @file   FITKAbaqusINPReader.h
 * @brief  Abaqus INP 读取， 继承自线程任务。
 * @author fulipeng (flipengqd@yeah.net)
 * @date   2024-03-07
 *
 *********************************************************************/
#ifndef __FITKABAQUSINPREADER_H__
#define __FITKABAQUSINPREADER_H__

#include "FITKAbaqusIOINPInterface.h"
#include "FITK_Kernel/FITKCore/FITKCoreMacros.h"
#include "FITK_Interface/FITKInterfaceIO/FITKAbstractTextReader.h"

ForwardDeclarNS(Core, FITKAbstractDataObject);

namespace IO
{
    class InpKeyWordsChecker;
    class InpReadInformationMapper;
    /**
    * @brief Abaqus INP 文件读取器
    * @author fulipeng (fulipengqd@yeah.net)
    * @date 2024-03-07
    */
    class FITKAbaqusINPReader : public Interface::FITKAbstractTextReader
    {
    public:
        /**
         * @brief Construct a new FITKAbaqusINPReader object
         * @param[i]  level          读取层次
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-03-19
         */
        explicit FITKAbaqusINPReader(INPReadLevel level);
        virtual ~FITKAbaqusINPReader();

        /**
         * @brief 重写run函数
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-03-11
         */
        void run() override;

        /**
         * @brief 设置是否跳过空行
         * @param[i] isSkip 
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-27
         */
        void setSkipBlankLine(bool isSkip);

        /**
         * @brief 读取一行数据
         * @return 一行数据
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-03-15
         */
        virtual QString readLine() override;

        /**
         * @brief 回退一行数据
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-27
         */
        virtual void backLine() override;

        /**
         * @brief 上一行的值
         * @return QString
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-04-19
         */
        //virtual QString previousLine() override;
        /**
         * @brief 获取映射表
         * @return InpReadInformationMapper*
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-21
         */
        InpReadInformationMapper* getReadInpInformationMapper();

        /**
         * @brief 获取读取等级
         * @return 读取等级
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-03-25
         */
        INPReadLevel getINPReadLevel();

        /**
         * @brief 检查关键字合法性
         * @param[i]  header         关键字行头
         * @param[i]  keys           关键字
         * @param[i]  keyValues      读取的关键字的值
         * @return true
         * @return false
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-03-19
         */
        bool checkKeyWords(const QString& header, const QStringList& keys, const QHash<QString, QString>& keyValues);

        /**
         * @brief 打印控制台消息
         * @param[i] level 打印级别 1 normal 2 warning 3error
         * @param[i] str 数据
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-04-07
         */
        void consoleMessage(int level, const QString& str) override;

    private:

        /**
         * @brief 读取等级 默认由inpInterface初始化
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-03-08
         */
        INPReadLevel _readLevel;
        /**
         * @brief 关键字检查器
         * @author LiBaojun (libaojunqd@foxmail.com)
         * @date 2024-03-19
         */
        InpKeyWordsChecker* _keyWordsChecker{};
        /**
         * @brief 映射器
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-21
         */
        InpReadInformationMapper* _informationReadInpMapper{};
        /**
         * @brief 是否跳过空行
         * @author liuzhonghua (liuzhonghuaszch@163.com)
         * @date 2024-06-27
         */
        bool _isSkipBlankLine{ true };
    };
}


#endif
